#include <iostream>
#include <algorithm>
#include <vector>

std::vector<int> getVector(int len)
{
    std::vector<int> vector{};
    for (int i = 0; i < len; i++)
    {
        vector.push_back(rand() % 40);
    }
    return vector;
}

template <typename E>
void printVector(const std::vector<E> &vector)
{

    for (const E &ele : vector)
    {
        std::cout << ele << " ";
    }
    std::cout << std::endl;
}

int main(int argc, char const *argv[])
{
    srand(time(0));

    std::vector<int> v1 = getVector(10);
    printVector(v1);

    std::vector<int> v2{};
    v2.resize(v1.size());
    std::copy(v1.begin(), v1.end(), v2.begin());
    printVector(v2);
    std::vector<int> v3{};
    v3.resize(v2.size());
    std::copy_if(v1.begin(), v1.end(), v3.begin(), [](const int &i)
                 { return i % 2 == 0; });
    printVector(v3);

    std::vector<int> v4 = getVector(10);
    printVector(v4);
    std::replace(v4.begin(), v4.end(), v4[3], 99);
    printVector(v4);

    std::vector<int> v5{};
    v5.resize(v4.size());
    std::replace_copy(v4.begin(), v4.end(), v5.begin(), v4[2], 98);
    printVector(v4);
    printVector(v5);

    std::replace_if(
        v5.begin(), v5.end(), [](const int &i)
        { return i % 2 == 1; },
        999);
    printVector(v5);

    std::vector<int> v6 = getVector(10);
    printVector(v6);
    std::vector<int> v7 = getVector(3);
    printVector(v7);

    std::swap(v6, v7);
    printVector(v6);
    printVector(v7);

    return 0;
}
